package tester;

import javax.swing.*;

/**
 * Created by IntelliJ IDEA.
 * User: aleck
 * Date: 2007-9-24
 * Time: 10:16:56
 * To change this template use File | Settings | File Templates.
 */
public class MessageOutput {
  private static JTextArea textOut;

  public static void print(Object... args) {
    for (Object arg : args) {
      if (textOut != null) {
        textOut.append(arg.toString());
        textOut.setCaretPosition(textOut.getDocument().getLength());
      }
      System.out.print(arg.toString());
    }
  }

  public static void println(Object... args) {
    print(args);
    if (textOut != null) {
      textOut.append("\n");
      textOut.setCaretPosition(textOut.getDocument().getLength());
    }
    System.out.println();
  }

  public static JTextArea getTextOut() {
    return textOut;
  }

  public static void setTextOut(JTextArea textOut) {
    MessageOutput.textOut = textOut;
  }
}
